using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Entity;
using Microsoft.Xna.Framework;

namespace Spinning.Spinning.Scenes.ProcessScene.TabLayouts
{
    class TabLayoutScene : BaseScene
    {
        protected List<Tab> tabList=new List<Tab>();
        protected Tab currentTab;
        Vector2 TabPos=new Vector2(0);

        public void OnTabTouch(Tab tab)
        {
            foreach (Tab t in tabList)
            {
                t.IsSelect = (t == tab);
                if (t.IsSelect)
                    currentTab = t;
            }
        }

        protected override void UpdateSelf(GameTime gameTime)
        {
            base.UpdateSelf(gameTime);
            gh();
        }

        private void gh()
        {
            Vector2 p = TabPos + new Vector2(0, tabList[0]._frameSize.Y)/2;
            for (int i = 0; i < tabList.Count;i++ )
            {
                Tab t = tabList[i];
                p.X += (t._frameSize.X / 2f);
                t.Position = p;
                p.X += (t._frameSize.X / 2f);
            }
        }

        public void AddTab(Tab t) {
            tabList.Add(t);
            Attach(t);
            TouchManager.RegisteTouchArea(t);
        }

        public void SetselectTab(Tab t) {
            OnTabTouch(t);
        }

        public override BaseScene Clone()
        {
            throw new NotImplementedException();
        }
    }
}
